package com.example.controller;

import com.example.common.result.Result;
import com.example.entity.mes.File;
import com.example.entity.pojo.MqunitPage;
import com.example.service.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@CrossOrigin // 解决跨域
@RestController
@RequestMapping("/api/Sign")
@Api(tags = "审批章印文件管理前端控制器")
public class SignController {

    @Resource
    private FileService fileService;

    @ApiOperation("新增文件")
    @PostMapping("/insert")
    public Result insert(@RequestBody File file){
        return this.fileService.insert(file);
    }

    @ApiOperation("删除文件")
    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Long id){
        return this.fileService.delete(id);
    }

    @ApiOperation("修改文件")
    @PutMapping("/update")
    public Result update(@RequestBody File file){
        return this.fileService.update(file);
    }

    @ApiOperation("分页查询文件")
    @PostMapping("/queryPageList")
    public Result<Map<String, File>> queryPageList(@RequestBody MqunitPage mqunitPage){
        return this.fileService.queryPageList(mqunitPage);
    }

    @ApiOperation("通过主键id查询文件")
    @GetMapping("/{id}")
    public Result<File> queryById(@PathVariable Long id){
        return this.fileService.queryById(id);
    }

    @ApiOperation("通过员工编号查询签章")
    @PostMapping("/queryCodeSign")
    public Result<File> queryCodeSign(@RequestBody List<String> codes){
        return this.fileService.queryCodeSign(codes);
    }
}
